package com.ruibang.glass.produce.controller.jq;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.produce.domain.req.MachiningReq;
import com.ruibang.glass.produce.entity.DbMachining;
import com.ruibang.glass.produce.entity.JqMachining;
import com.ruibang.glass.produce.service.DbMachiningService;
import com.ruibang.glass.produce.service.JqMachiningService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-01-25  16:41
 * @Description: TODO：精切加工参数控制器
 * @Version: 1.0
 */

@Api(tags = "精切加工参数控制器")
@RestController
@RequestMapping("/api/glass/produce/jq/machining")
public class JqMachiningController {

    @Autowired
    private JqMachiningService jqMachiningService;

    @PostMapping("/pageQuery")
    @ApiOperation(value = "精切加工参数数据", response = ResultBody.class)
    public ResultBody<IPage<JqMachining>> pageQuery(@RequestBody @Valid MachiningReq machiningReq) {
        return ResultBody.success(jqMachiningService.pageQuery(machiningReq));
    }

    @PostMapping("/export")
    @ApiOperation(value = "数据导出", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void export(@RequestBody @Valid MachiningReq machiningReq, HttpServletResponse response) {
        jqMachiningService.export(machiningReq, response);
    }
}
